{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 🧑‍🍳 L3 - Organizing the tools you make for later reuse"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 🔖 Reminder: All ✨ generative responses result from having the model fill in the _____.\n",
    "\n",
    "![](./assets/completion.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "1. Grow the existing business\n",
    "2. Save money and time\n",
    "3. Add completely new business\n",
    "4. Prepare for the unknown"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "height": 301
   },
   "outputs": [],
   "source": [
    "import semantic_kernel as sk\n",
    "from semantic_kernel.connectors.ai.open_ai import AzureChatCompletion, OpenAIChatCompletion\n",
    "from IPython.display import display, Markdown\n",
    "\n",
    "kernel = sk.Kernel()\n",
    "\n",
    "useAzureOpenAI = False\n",
    "\n",
    "if useAzureOpenAI:\n",
    "    deployment, api_key, endpoint = sk.azure_openai_settings_from_dot_env()\n",
    "    kernel.add_text_completion_service(\"azureopenai\", AzureChatCompletion(deployment, endpoint, api_key))\n",
    "else:\n",
    "    api_key, org_id = sk.openai_settings_from_dot_env()\n",
    "    kernel.add_text_completion_service(\"openai\", OpenAIChatCompletion(\"gpt-3.5-turbo-0301\", api_key, org_id))\n",
    "\n",
    "print(\"A kernel is now ready.\")    "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "```directory\n",
    "plugins-sk/\n",
    "│\n",
    "└─── BusinessThinking/\n",
    "     |\n",
    "     └─── BasicStrategies/\n",
    "     |    └─── config.json\n",
    "     |    └─── skprompt.txt\n",
    "     |\n",
    "     └─── SeekCostEfficiency/\n",
    "     |    └─── config.json\n",
    "     |    └─── skprompt.txt\n",
    "     |\n",
    "     └─── SeekTimeEfficiency/\n",
    "          └─── config.json\n",
    "          └─── skprompt.txt\n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Note**, LLM's do not always produce the same results. Your results may differ from the video."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Note**: To see the plugins directory, select 'file' at the top of the jupyter notebook. Then select 'open'. This will open a tab with a file directory view where you can see the plugins-sk directory and examine the files used in this lab."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "height": 284
   },
   "outputs": [],
   "source": [
    "strengths = [ \"Unique garlic pizza recipe that wins top awards\",\"Owner trained in Sicily at some of the best pizzerias\",\"Strong local reputation\",\"Prime location on university campus\" ]\n",
    "weaknesses = [ \"High staff turnover\",\"Floods in the area damaged the seating areas that are in need of repair\",\"Absence of popular calzones from menu\",\"Negative reviews from younger demographic for lack of hip ingredients\" ]\n",
    "\n",
    "pluginsDirectory = \"./plugins-sk\"\n",
    "\n",
    "pluginBT = kernel.import_semantic_skill_from_directory(pluginsDirectory, \"BusinessThinking\");\n",
    "\n",
    "my_context = kernel.create_new_context()\n",
    "my_context['input'] = 'makes pizzas'\n",
    "my_context['strengths'] = \", \".join(strengths)\n",
    "my_context['weaknesses'] = \", \".join(weaknesses)\n",
    "\n",
    "costefficiency_result = await kernel.run_async(pluginBT[\"SeekCostEfficiency\"], input_context=my_context)\n",
    "costefficiency_str = str(\"### ✨ Suggestions for how to gain cost efficiencies\\n\" + str(costefficiency_result))\n",
    "display(Markdown(costefficiency_str))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "height": 284
   },
   "outputs": [],
   "source": [
    "opportunities = [ \"Untapped catering potential\",\"Growing local tech startup community\",\"Unexplored online presence and order capabilities\",\"Upcoming annual food fair\" ]\n",
    "threats = [ \"Competition from cheaper pizza businesses nearby\",\"There's nearby street construction that will impact foot traffic\",\"Rising cost of cheese will increase the cost of pizzas\",\"No immediate local regulatory changes but it's election season\" ]\n",
    "\n",
    "pluginBT = kernel.import_semantic_skill_from_directory(pluginsDirectory, \"BusinessThinking\");\n",
    "\n",
    "my_context = kernel.create_new_context()\n",
    "my_context['input'] = 'makes pizzas'\n",
    "my_context['strengths'] = \", \".join(strengths)\n",
    "my_context['weaknesses'] = \", \".join(weaknesses)\n",
    "my_context['opportunities'] = \", \".join(opportunities)\n",
    "my_context['threats'] = \", \".join(threats)\n",
    "\n",
    "bizstrat_result = await kernel.run_async(pluginBT[\"BasicStrategies\"],input_context=my_context)\n",
    "bizstrat_str = \"## ✨ Business strategy thinking based on SWOT analysis\\n\"+str(bizstrat_result)\n",
    "display(Markdown(bizstrat_str))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Another way to think of it is the famous \"bucket of time\" and \"bucket of money\" depiction of a business owner.\n",
    "\n",
    "![](./assets/shopkeeper.png)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "height": 29
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.17"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
